

function updateStatus () {
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-expect-error
  const player = $('video')?.[0]?.player
  const timer = player?.getCurrentTime()
  const duration = player?.getDuration()
  const status = player?.getStatus()

  window.parent.postMessage({
    timer,
    duration,
    status
  })
}


function init(){
  setInterval(updateStatus,1000)
  window.addEventListener('message', (e) => {
    const player = ($('video')?.[0] )?.player
    if(e.data === 'play'){
      player?.play()
    }
  })
}

export const playerRender = () => {
  console.log('playerRender')

  init()
}

